<#include "/layout/header.ftl" />
<#import "/include/ui.ftl" as blue />

<script src="${rc_path}/js/jquery/jquery-treetable.js"></script>
<script>

$(function()
{
	$("#tbl_tree").treetable({expandable : true, expanderTemplate : "<a>&nbsp;</a>"});
	
});

function search_click()
{
	var obj = $.getObject("#div_search");	
	$("#div_grid").simpleLoad("/cms/channel_list", obj, 1);
	
}

function web_change()
{
	var webId = $("#slt_web").val();
	window.location = "${path}/cms/channel_list?webId=" + webId;
}


</script>

<div class="am-g am-cf am-margin-top am-margin-bottom">
	<div class="am-u-sm-3 am-padding-right-0">
		<div class="am-btn-group">
			<a href="${path}/cms/channel_get?webId=${model.webId!}" class="am-btn am-btn-primary am-radius">添加</a>
			<a href="${path}/cms/web_list" class="am-btn am-btn-danger am-radius">返回</a>
			<a href="javascript:void(0)" onclick="blue_refresh_click('/cms/channel_refresh')" class="am-btn am-btn-default am-radius">刷新缓存</a>
		</div>
	</div>
	<div class="am-u-sm-9 am-form-inline" id="div_search">
		<div class="am-form-group">
			<select id="slt_web" name="webId" data-am-selected="{'btnWidth': '120px'}" onchange="web_change()">
				<@blue.select list=webList value=model.webId />
			</select>
		</div>

	</div>
</div>

<div class="am-g" id="div_grid">
	<div class="am-u-sm-12">
		<table class="am-table am-table-striped am-table-hover" id="tbl_tree">
			<thead>
			<tr>
				<th width="300">名称</th>
				<th width="150">标识</th>
				<th width="100">栏目类型</th>
				<th width="100">文档模型</th>
				<th width="100">状态</th>
				<th width="100">文档数</th>
				<th width="100">排序</th>
				<th width="200">操作</th>
			</tr>
			</thead>
			<tbody>
			<#if treeList?? && treeList?size &gt; 0>
			<@tree map=treeList key="0" />
			</#if>
			</tbody>
		</table>
	</div>
</div>

<#macro tree map key count=0>
	<#assign voList=map[key]! />
	
	<#if voList??>
	<#list voList as vo>
			<tr data-tt-id="${vo.id}" data-tt-parent-id="${vo.parentId!}">
				<td title="${vo.name!}">${vo.name!}</td>
				<td>${vo.code!}</td>
				<td>${vo.type!}</td>
				<td>${vo.model!}</td>
				<td>${vo.state!}</td>
				<td>${vo.docs!}</td>
				<td>${vo.sort!}</td>
				<td>
					<div class="am-btn-group">
						<a href="${path}/cms/channel_get?id=${vo.id}" class="am-btn am-btn-primary am-btn-sm am-radius">编辑</a>
						<a href="${path}/cms/channel_get?parentId=${vo.id}&webId=${model.webId!}" class="am-btn am-btn-danger am-btn-sm am-radius">子栏目</a>
						<a href="${path}/cms/doc_list?channelId=${vo.id}&webId=${model.webId!}" class="am-btn am-btn-default am-btn-sm am-radius">文档</a>
					</div>
				</td>
			</tr>
			<@tree map=map key=vo.id?string count=count+1 />
	</#list>
	</#if>
	
</#macro>

<#include "/layout/footer.ftl" />